function y = ylddisc(sd,md,rv,price,basis) 
%YLDDISC Yield of discounted security. 
%   Y = YLDDISC(SD,MD,RV,PRICE,BASIS) finds the yield of a discounted 
%   security 
%
%   rv = ylddisc(sd,md,rv,price) 
%   rv = ylddisc(sd,md,rv,price,basis) 
%
%   Enter dates as serial date numbers or date strings.
%
%   Inputs:
%       SD      -  Settlement date
%       MD      -  Maturity date
%       RV      -  Redemption value
%       PRICE   -  Discount rate
% 
%   Optional Inputs:
%       basis   -  the day-count basis:
%                  0 = actual/actual (default)
%                  1 = 30/360 SIA
%                  2 = actual/360
%                  3 = actual/365
%                  4 = 30/360 PSA
%                  5 = 30/360 ISDA
%                  6 = 30E/360
%                  7 = actual/365 Japanese
%                  8 - actual/actual ISMA
%                  9 - actual/360 ISMA
%                 10 - actual/365 ISMA
%                 11 - 30/360 ISMA
%                 12 - actual/365 ISDA
%                 13 - bus/252
%
%   Using the following data, 
%   
%      SD = '10/14/1988'
%      MD = '03/17/1989'
%      RV = 100
%      PRICE = 96.28
%      BASIS = 2
%       
%   y = ylddisc(sd,md,rv,price,basis)
%       
%   returns y = 0.0903 or 9.03%
% 
%   See also PRBOND, YLDBOND, YLDMAT, PRDISC. 
% 
%   Reference: Mayle, Standard Securities Calculation Methods, Volumes
%              I-II, 3rd edition.  Formula 1. 
 
% Copyright 1995-2006 The MathWorks, Inc.
% $Revision: 1.6.2.8 $   $Date: 2009/05/07 18:23:36 $ 
 
if nargin < 5 
  basis = zeros(size(rv)); % Default day count basis 
end 

if nargin < 4 
  error('finance:ylddisc:tooFewInputs',...
      'Missing one of SD, MD, RV, and DISC data.'); 
end 
 
[~, sd, md, ~, basis, ~, ~, ...
        ~, ~, ~, ~] = ...
                instargbond([],sd,md,[],basis,[],[],[],[],[],rv);
    
[sd,md,rv,price,basis] = ...
        finargsz(1,sd,md,rv,price,basis);
 
y = reshape((rv-price)./price.* ...
                        (1./yearfrac(sd,md,basis)),size(rv));